﻿using ArtMath.Component.Manager;
using ArtMath.Component.Point;
using ArtMath.Core.Helper;
using ArtMath.Data;
using ArtMath.Resource;
using System;
using System.ComponentModel;

namespace ArtMath.Component.Line
{
    /// <summary>
    /// 角等分射线
    /// </summary>
    [Serializable]
    public class AngleDividerRay : RayBase
    {
        AngleNDivider divr;
        public AngleDividerRay(SketchPad pad, string name, AngleNDivider divr) : base(pad, name, ToolTypeName.jdfsx, false)
        {
            this.divr = divr;
            InPoints = new PointBase[1];
        }
        public override double NewDirectedAngle
        {
            get
            {
                if (divr.NewDirectedAngles.TryGetValue(this, out double res))
                {
                    return res;
                }
                return base.NewDirectedAngle;
            }
        }
        public override string Name
        {
            get
            {
                return base.Name;
            }

            set
            {
                if (!string.IsNullOrEmpty(value))
                {
                    if (divr != null && divr.CheckLineNameExist(value))
                    {
                        value = Utility.GetNextAvailableName(value, divr.CheckLineNameExist);
                    }
                }
                base.Name = value;
            }
        }
        [Browsable(false)]
        public override RPointS RotateCenter
        {
            get
            {
                return base.RotateCenter;
            }

            set
            {
                base.RotateCenter = value;
            }
        }
        [Browsable(false)]
        public override AngleStringX RotateAngle
        {
            get
            {
                return base.RotateAngle;
            }

            set
            {
                base.RotateAngle = value;
            }
        }
        public override ComponentManagerBase ComponentManager
        {
            get
            {
                return divr;
            }
        }
        //public override void CreateComponents()
        //{
        //    if (SourcePoint == null)
        //    {
        //        SourcePoint = Pad.CreatePoint(Resources.JoinLocalizedString("Source", "Point"), SpareCoordinate_);
        //        SpareCoordinate_ = SourcePoint.Pxy;
        //        Pad.TrackObj = this;
        //        base.CreateComponents();
        //    }
        //}
    }
}
